
import glob
import os
import sys
import time
import argparse
# ==============================================================================
# -- Find CARLA module ---------------------------------------------------------
# ==============================================================================

try:
    sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
        sys.version_info.major,
        sys.version_info.minor,
        'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
    pass

# ==============================================================================
# -- Add PythonAPI for release mode --------------------------------------------
# ==============================================================================
try:
    sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/carla')
    sys.path.append("../examples/")
except IndexError:
    pass

import carla

# Connect to the client and retrieve the world object
try:
    argparser = argparse.ArgumentParser(
        description=__doc__)
    argparser.add_argument(
        '--map',
        metavar='H',
        default='Town01',
        type=str,
        help='map')


    args = argparser.parse_args()
    client = carla.Client('127.0.0.1', 2000)
    # world = client.get_world()
    client.load_world(args.map)

    
    # print(actor)
    # print(actor.type_id)
    # print(transform)
    time.sleep(2)
        # world.tick()


    # ego_vehicle_actor=actors.find(263)
    # location=ego_vehicle_actor.get_location()
    # transform=ego_vehicle_actor.get_transform()
    # print(location)
    # print(transform)
    # client.load_world('Town01')
    # client.set_timeout(20.0)
    # for i in range(len(client.get_available_maps())):
    #     print(client.get_available_maps()[i])
except IndexError:
    pass